package com.dfbz.netctoss.controller;

import com.dfbz.netctoss.Result;
import com.dfbz.netctoss.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;


@Controller
@RequestMapping("/account")
public class AccountController {

    @Autowired
    AccountService service;

    @RequestMapping("toList")
    public String toIndex(){
        return "account/account_list";
    }

    @RequestMapping("selectPage/{pageNum}/{pageSize}")
    @ResponseBody
    public Result selectPage(@PathVariable int pageNum, @PathVariable int pageSize){
        return new Result(true, "查询成功", service.selectPage(pageNum, pageSize));
    }

    @RequestMapping("toDetail")
    public String toDetail(){
        return "account/account_detail";
    }

    @RequestMapping("selectOne/{id}")
    @ResponseBody
    public Result selectOne(@PathVariable int id){
        return new Result(true, "查询成功", service.findByAId(id));
    }
}
